<template>
	<view class="uni-padding-wrap uni-common-mt">
		<view class="uni-pagination-box">
			<uni-pagination :page-size="pageSize" :current="pageNo" :total="rowCount" @change="changePage"  />
		</view>
		<view class="uni-container">
			<hotel-order-list :dataList="dataList" :loading="loading"></hotel-order-list>
		</view>
		<view class="uni-pagination-box">
			<uni-pagination :page-size="pageSize" :current="pageNo" :total="rowCount" @change="changePage"  />
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onShow,
		onLoad,
    onNavigationBarButtonTap
	} from '@dcloudio/uni-app'
	import {
		searchHotelOrders,
		showHotelOrderStatus
	} from "@/common/api/hotel.js";

	import HotelOrderList from '@/components/list/hotel-order-list_h5.vue'

	let dataList = ref([])
	let loading = ref(false)

	let rowCount = ref(0)
	let pageNo = ref(1)
	let pageSize = ref(10)
	let pageTotal = ref(0)
	
	onLoad(() => {
		console.log('onLoad......')
		search();
	})
	
	onShow(() => {
		console.log('onShow......')
	 })

	function search() {
		loading.value = true
		const params = {
			"sc.pageNo": pageNo.value,
			"sc.pageSize": pageSize.value,
		};
		dataList.value.splice(0)
		searchHotelOrders(
			params,
			(v) => {
				dataList.value = v.dataList;

				pageNo.value = v.page.pageNo
				pageTotal.value = v.page.pageTotal
				rowCount.value = v.page.rowCount
				
				// console.log(pageNo, pageTotal, rowCount)
				
			},
			() => {
				loading.value = false
			}
		);
	}
	
	function changePage(e) {
		pageNo.value = e.current
		search()
	}


  onNavigationBarButtonTap((e) => {
    console.log(e)
    if (e.type === 'home') {
      uni.reLaunch({url: '/pages/home/home'})
    }
  });
</script>
